package com.nf.practice.fileconvert;

import org.junit.jupiter.api.Test;
import org.junit.platform.commons.util.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ExcelToSql {

    @Test
    public void test() {
        Map<String,String> originalParams = new HashMap<>();
        originalParams.put("appNo", "123456789");
        originalParams.put("creditCode", "98712356700");
        originalParams.put("tagCode", "QY14");
        originalParams.put("name", "金融科技");
        originalParams.put("idNo", "1256789xxxx000");
        // 初始化文件内容
        String jsonHeader = "{\"appNo\":\"" + originalParams.get("appNo")
                + "\",\"creditCode\":\""
                + originalParams.get("creditCode")
                + "\",\"tagCode\":\""
                + originalParams.get("tagCode")
                + "\",\"name\":\""
                + originalParams.get("name")
                + "\",\"idNo\":\""
                + originalParams.get("idNo")
                + "\",\"data\":";
        String jsonFooter = "}\n";

        String content = "{\"goodsNo\":\"0009100006\",\"saveDate\":\"2021-11-30\",\"billType\":\"销售\"}";
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < 3; i++) {
            stringBuilder.append(jsonHeader).append(content).append(jsonFooter);
        }
        System.out.println(stringBuilder);
    }


    // 读取行数据
//    @Test
//    public void test1() {
//        Workbook workbook = new XSSFWorkbook(new FileInputStream(new File("D://11.xlsx")));
//        Sheet sheet = workbook.getSheet("Sheet3");
//        System.out.println(sheet.getSheetName());
//
//        List<String> results = new ArrayList<>();
//        Iterator<Row> iterator = sheet.rowIterator();
//        while (iterator.hasNext()){
//            Row row = iterator.next();
//            String alterSql = "ALTER table "+row.getCell(0)+" modify "+row.getCell(1)+" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP;";
//            System.out.println(alterSql);
////      results.add(alterSql);
//
//        }
//    }

}
